﻿<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="urn:schemas-microsoft-com:office:spreadsheet"
                xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
                xmlns:sp="http://schemas.microsoft.com/sharepoint/"
                exclude-result-prefixes="msxsl">
  <xsl:output method="xml" indent="yes"/>

  <!--
===================================================================================================================
  Onglet [Types de contenus]
===================================================================================================================
-->
  <xsl:template name="Onglet_ContentType">
    <Worksheet ss:Name="Types de contenus">
      <Table>
        <Row>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">...</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">ID [ContentType]</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">ID [Field]</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">Name [ContentType]</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">Name [Field]</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">DisplayName [Field]</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">Group</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">FeatureId</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">Feature Name</Data>
          </Cell>
          <Cell ss:StyleID="headerStyle">
            <Data ss:Type="String">SolutionId</Data>
          </Cell>
        </Row>
        <xsl:apply-templates select="//ContentType"/>
      </Table>
      <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"/>
    </Worksheet>
  </xsl:template>

  <!--
===================================================================================================================
  Template [ContentType]
===================================================================================================================
-->
  <xsl:template match="ContentType">
    <Row ss:StyleID="mainLine">
      <!-- ... -->
      <Cell>
        <Data ss:Type="String">ContentType</Data>
      </Cell>
      <!-- ID [ContentType] -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@ID"/>
        </Data>
      </Cell>
      <!-- ID [Field] -->
      <Cell>
        <Data ss:Type="String"/>
      </Cell>
      <!-- Name [ContentType] -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Name"/>
        </Data>
      </Cell>
      <!-- Name [Field] -->
      <Cell>
        <Data ss:Type="String"/>
      </Cell>
      <!-- DisplayName [Field] -->
      <Cell>
        <Data ss:Type="String"/>
      </Cell>
      <!-- Group -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Group"/>
        </Data>
      </Cell>
      <!-- FeatureId -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="ancestor::*[name() = 'Feature']/@Id"/>
        </Data>
      </Cell>
      <!-- Feature Name -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="ancestor::*[name() = 'Feature']/@Title"/>
        </Data>
      </Cell>
      <!-- SolutionId -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="ancestor::*[name() = 'Solution']/@Id"/>
        </Data>
      </Cell>
    </Row>
    <xsl:apply-templates select="FieldRefs/FieldRef" mode="ContentTypeFieldRef"/>
  </xsl:template>

  <!--
===================================================================================================================
  Template [FieldRef]
===================================================================================================================
-->
  <xsl:template match="FieldRef" mode="ContentTypeFieldRef">
    <Row>
      <!-- ... -->
      <Cell>
        <Data ss:Type="String">FieldRef</Data>
      </Cell>
      <!-- ID [ContentType] -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="ancestor::*[name() = 'ContentType']/@ID"/>
        </Data>
      </Cell>
      <!-- ID [Field] -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@ID"/>
        </Data>
      </Cell>
      <!-- Name [ContentType] -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="ancestor::*[name() = 'ContentType']/@Name"/>
        </Data>
      </Cell>
      <!-- Name [Field] -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@Name"/>
        </Data>
      </Cell>
      <!-- DisplayName [Field] -->
      <Cell>
        <Data ss:Type="String">
          <xsl:value-of select="@DisplayName"/>
        </Data>
      </Cell>
    </Row>
  </xsl:template>

</xsl:stylesheet>
